package com.authorization.authcode.controller;

import org.springframework.web.bind.annotation.RestController;

import java.security.Principal;

import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;


@RestController
public class TestController{
    @RequestMapping(value="/", method=RequestMethod.GET)
    public String index() {
        return "HelloWorld !";
    }

    @RequestMapping(value="/home", method=RequestMethod.GET)
    public String home(Principal principal, Authentication a) {
         for(var auth:	a.getAuthorities()) {
        	 System.out.println(auth.getAuthority());
         }
        return principal.getName()+" home !";
    }

}